home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mntdoc01.zoo / mintdoc / cat2 / psetlimit.nr < prev    next >
Encoding:
Text File  |  1993-03-03  |  3.6 KB  |  133 lines

  1.  
  2.  
  3.  
  4. Psetlimit(2)               Oct. 1, 1991              Psetlimit(2)
  5.  
  6.  
  7. N✓NA✓AM✓ME✓E
  8.        Psetlimit - get or set limits on use of system resources
  9.  
  10. S✓SY✓YN✓NO✓OP✓PS✓SI✓IS✓S
  11.        LONG Psetlimit( WORD lim, LONG value );
  12.  
  13. D✓DE✓ES✓SC✓CR✓RI✓IP✓PT✓TI✓IO✓ON✓N
  14.        _✓P_✓s_✓e_✓t_✓l_✓i_✓m_✓i_✓t  gets  or  sets  a resource limit for a process.
  15.        Which limit is affected is governed by the value  of  _✓l_✓i_✓m,
  16.        as follows:
  17.            1: get/set maximum CPU time for process (in milliseconds)
  18.            2: get/set total maximum memory allowed for process
  19.            3: get/set limit on Malloc'd memory for process
  20.  
  21.        If  _✓v_✓a_✓l_✓u_✓e is negative, the limit is unchanged; if _✓v_✓a_✓l_✓u_✓e is
  22.        0, the corresponding resource is unlimited; otherwise, the
  23.        resource limit is set to _✓v_✓a_✓l_✓u_✓e.
  24.  
  25.  
  26.        Setting  the  "maximum  memory" limit means the process is
  27.        not allowed to grow bigger than that size overall. Setting
  28.        the  "maximum  Malloc'ed" limit means that the process may
  29.        allocate no more than that much memory. The difference  is
  30.        that  the  latter  limit  applies  above  and  beyond  the
  31.        text+data+bss size of the process.
  32.  
  33.  
  34.        Using Psetlimit sets the corresponding limit for both  the
  35.        process  and any children it creates thereafter. Note that
  36.        the limits apply to each process individually; setting the
  37.        child  CPU  limit  value to 1000 and then using _✓f_✓o_✓r_✓k(2) to
  38.        create three children results in each  of  those  children
  39.        getting  a CPU limit value of one second. They do not have
  40.        a _✓c_✓o_✓l_✓l_✓e_✓c_✓t_✓i_✓v_✓e or _✓s_✓u_✓m _✓t_✓o_✓t_✓a_✓l limit of one second.
  41.  
  42.  
  43.        There is no restriction on _✓i_✓n_✓c_✓r_✓e_✓a_✓s_✓i_✓n_✓g a limit. Any process
  44.        may  set  any  of its limits or its childrens' limits to a
  45.        value greater than its current  limit,  or  even  to  zero
  46.        (unlimited).
  47.  
  48.  
  49.        Memory limits do not apply during execution of Pexec; that
  50.        is, if a process is limited to (say) 256KB of  memory,  it
  51.        can still exec a child which uses more memory.
  52.  
  53.  
  54.        Memory limits are not retroactive: if a process owns 256KB
  55.        of memory and then calls Psetlimit to restrict  itself  to
  56.        128KB, it will not be terminated, but no Malloc calls will
  57.        succeed until its size drops below 128KB.
  58.  
  59.  
  60.        CPU limits are retroactive, however: if a process has used
  61.  
  62.  
  63.  
  64. Version 0.9          MiNT Programmer's Manual                   1
  65.  
  66.  
  67.  
  68.  
  69.  
  70. Psetlimit(2)               Oct. 1, 1991              Psetlimit(2)
  71.  
  72.  
  73.        three  CPU  seconds and calls Psetlimit to restrict itself
  74.        to one second, it will  immediately  receive  SIGXCPU  and
  75.        terminate.
  76.  
  77.  
  78. R✓RE✓ET✓TU✓UR✓RN✓NS✓S
  79.        The old limit (0 if there was no limit).
  80.  
  81.  
  82. B✓BU✓UG✓GS✓S
  83.        Since  the  limit applies to the process and its children,
  84.        you can't limit a child to, say, one  millisecond  of  CPU
  85.        time: the parent must necessarily limit itself before cre-
  86.        ating the child, and if it has used more than a  millisec-
  87.        ond  itself,  it  will die with SIGXCPU.  A new set of _✓l_✓i_✓m
  88.        arguments is needed that  apply  to  the  caller's  future
  89.        children without applying to the caller.
  90.  
  91.  
  92.        To  alleviate this, the parent must create a child process
  93.        via Pvfork, and _✓t_✓h_✓i_✓s process (which  hasn't  consumed  any
  94.        CPU time yet) must call Psetlimit and then Pexec to create
  95.        the child that is meant to be limited.
  96.  
  97.  
  98. S✓SE✓EE✓E A✓AL✓LS✓SO✓O
  99.        _✓P_✓r_✓u_✓s_✓a_✓g_✓e(2)
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130. Version 0.9          MiNT Programmer's Manual                   2
  131.  
  132.  
  133.